//package com.example.demo.job.scheduledTask;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.Trigger;
//import org.springframework.scheduling.TriggerContext;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.SchedulingConfigurer;
//import org.springframework.scheduling.config.ScheduledTaskRegistrar;
//import org.springframework.scheduling.support.CronTrigger;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.Date;
//
//
//@RestController
//@EnableScheduling
//public class ChangeTask implements SchedulingConfigurer {
//
//    @Value("${task.expression}")
//    String expression;
//
////    //时间:秒，分钟，小时，日期，月份，星期，年
////    private String expression = "0/5 * * * * *";
//
//    //编写更改调度时间的方法
//    @RequestMapping("change")
//    public String changeExpression() {
//        expression = "0/10 * * * * *";
//        return "changeExpression";
//    }
//
//
//    @Override
//    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
//        //定时任务要执行的方法
//        Runnable task = new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("changeTask" + new Date());
//            }
//        };
//        /**
//         * 调度实现的时间控制
//         */
//        Trigger trigger = new Trigger() {
//            @Override
//            public Date nextExecutionTime(TriggerContext triggerContext) {
//                CronTrigger cronTrigger = new CronTrigger(expression);
//                return cronTrigger.nextExecutionTime(triggerContext);
//            }
//        };
//        scheduledTaskRegistrar.addTriggerTask(task, trigger);
//    }
//
//}